package com.squid.templateProject.config.exception;

import com.squid.templateProject.bean.enums.SystemCodeMsgEnums;
import com.squid.templateProject.bean.enums.error.BaseErrorCodeMsg;

/**
 * Description
 *
 * @author jinhang
 * @since 2024-1-23
 **/
public class ExceptionFactory {
    public static ServerException instanceServerException(Integer code, String message) {
        return new ServerException(code, message);
    }

    public static ServerException instanceServerException(String message) {
        return new ServerException(SystemCodeMsgEnums.ERROR.getCode(), message);
    }

    public static ServerException instanceServerException(BaseErrorCodeMsg enums) {
        return new ServerException(enums.getCode(), enums.getMessage());
    }

    public static BusinessException instanceBusinessException(Integer code, String message) {
        return new BusinessException(code, message);
    }

    public static BusinessException instanceBusinessException(String message) {
        return new BusinessException(SystemCodeMsgEnums.ERROR.getCode(), message);
    }

    public static BusinessException instanceBusinessException(BaseErrorCodeMsg enums) {
        return new BusinessException(enums.getCode(), enums.getMessage());
    }
}
